<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="校验名:" prop="checkName">
          <el-input
            v-model="formModel.checkName"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-form-item class="no-warn-item" label="校验代码:" prop="checkNo">
          <el-input
            v-model="formModel.checkNo"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button type="primary" v-if="hasPermission('checkRuleConfig_select')" plain @click="queryList(false)">查询
            </el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :table-data="tableData" :columns="columns" :is-select="false">
      <template slot="tools">
        <el-table-column
          label="操作"
          width="80"
          fixed="right"
          header-align="center"
          align="center"
        >
          <template slot-scope="{row}">
            <span class="hey_tools_btn" v-if="hasPermission('checkRuleConfig_edit',row)" @click="handleEdit(row)">编辑</span>
          </template>
        </el-table-column>
      </template>
    </hey-table>
    <el-dialog
      v-if="dialogVisible"
      :close-on-click-modal="false"
      title="校验规则配置"
      :visible.sync="dialogVisible"
      width="60%"
    >
      <CheckRuleConfig-mnt :page-type="operType" :edit-data="editData" @mntSuc="queryList"/>
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: 'CheckRuleConfigList',
  components: {
    CheckRuleConfigMnt: () => import('./checkRuleConfig-mnt')
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      operaType: '',
      editData: {},
      tableData: [],
      formModel: {
        checkName: '',
        checkNo: ''
      },
      columns: [
        {title: '校验名', key: 'checkName'},
        {title: '校验代码', key: 'checkNo'},
        {title: '校验范围', key: 'checkRange'},
        {title: '正则表达式', key: 'regex'},
        {title: '长度', key: 'length'},
        {title: '创建时间', key: 'createTime'},
        {title: '创建人', key: 'createUsername'},
        {title: '最后修改时间', key: 'lastUpdateTime'},
        {title: '最后修改人', key: 'lastUpdateUsername'}
      ]
    }
  },
  computed: {},
  mounted() {
  },
  methods: {
    queryList() {
      this.$refs.table.query('/checkRuleConfig/page', this.formModel, '', false)
    },
    handleAdd() {
      this.operType = 'add'
      this.dialogVisible = true
    },
    handleEdit(row) {
      this.dialogVisible = true
      this.operType = 'edit'
      this.editData = row || {}
    },
    handleDelete(row) {
      this.$sure('确认删除？', _ => {
        this.post('checkRuleConfig/delete', {checkRuleConfigId: row.checkRuleConfigId}).then(_ => {
          this.$info('删除成功', this.queryList)
        })
      })
    }
  }
}
</script>

